package edu.gdit.health.controller;

import com.alibaba.druid.support.logging.Log;
import com.alibaba.druid.support.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

@Controller
//可以对外访问，并检查访问者是否有登陆权限和操作权限
@RequestMapping("/api")//定义访问形式，所有访问者都通过这个目录进行访问
public class ApiController {
    private static final Log log = LogFactory.getLog(ApiController.class);
//    @RequestMapping("/test")//分级
//    public String test(){
//        return "test";
//    }
//    @RequestMapping("/test1")//分级
//    public ModelAndView test(ModelAndView mv){
//        mv.setViewName("index");
//        return mv;
//    }

    @RequestMapping("/getPage")
    public ModelAndView getPage(ModelAndView mv,String pageName)
    {
        log.warn("用户打开了新页面"+pageName);
        //如果pageName为空，则pageName=Index.html，否则自身不变
        pageName=null==pageName?"index":pageName;
        //设置转向视图的名称
        mv.setViewName(pageName);
        //mv.addObject设置一个数据
        mv.addObject("username","julia");
        mv.addObject("password","123456");
        //返回模型视图对象
        return mv;
    }
}
